You can interact with this notebook online: Launch notebook

How to Access Physical Quantities

In order to compute the synthetic spectrum, TARDIS must either be told or must calculate many physical properties of the model. To understand and test the code it can be important to look at these values. One easy way to do this is to run TARDIS in an interactive mode and then inspect the model properties.

Running an interactive Python session

[1]:
# Download the atomic data
from tardis.io.atom_data import download_atom_data
download_atom_data('kurucz_cd23_chianti_H_He')

# Download the example configuration file
!curl -O https://raw.githubusercontent.com/tardis-sn/tardis/master/docs/tardis_example.yml
Configuration File /home/runner/.astropy/config/tardis_internal_config.yml does not exist - creating new one from default
CRITICAL:root:
********************************************************************************

TARDIS will download different kinds of data (e.g. atomic) to its data directory /home/runner/Downloads/tardis-data

TARDIS DATA DIRECTORY not specified in /home/runner/.astropy/config/tardis_internal_config.yml:

ASSUMING DEFAULT DATA DIRECTORY /home/runner/Downloads/tardis-data
 YOU CAN CHANGE THIS AT ANY TIME IN /home/runner/.astropy/config/tardis_internal_config.yml

********************************************************************************


WARNING:tardis.io.atom_data.atom_web_download:Atomic Data kurucz_cd23_chianti_H_He already exists in /home/runner/Downloads/tardis-data/kurucz_cd23_chianti_H_He.h5. Will not download - override with force_download=True.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   980  100   980    0     0   4665      0 --:--:-- --:--:-- --:--:--  4688
[2]:
from tardis import run_tardis

simulation = run_tardis('tardis_example.yml')

If all goes well, the simulation should run as usual. Afterwards, the information from the simulation will all exist in Simulation and can be examined. Some examples for useful/interesting quantities are given below (but much more information is available: contact us via tardis-sn-users if you need further help).

Examples of finding physical quantities

For example, two of our important quantities are the parameters of the radiation field model, \(T_{\rm rad}\) and \(W\). These exist as numpy.ndarray

Thus simulation.plasma.t_rad will give you a list of the \(T_{\rm rad}\)-values for the model zones in cgs units.

[3]:
simulation.plasma.t_rad
[3]:
array([11083.07938222, 11172.62291753, 11284.48213205, 11397.74038154,
       11331.02086708, 11428.27356529, 11351.34532552, 11306.6822121 ,
       11293.35191219, 11178.27403316, 11131.80156634, 11054.1024343 ,
       10961.89807644, 10901.19856578, 10792.35060936, 10697.01220593,
       10579.38561549, 10547.2273288 , 10467.97572806, 10360.55050532])

Similarly, the \(W\)-values can be accessed using simulation.plasma.w

[4]:
simulation.plasma.w
[4]:
array([0.46450351, 0.3580061 , 0.28288475, 0.22809946, 0.20052642,
       0.17078951, 0.15419983, 0.13956176, 0.12608471, 0.11750496,
       0.10913392, 0.10260794, 0.09736697, 0.09161782, 0.08773441,
       0.08396587, 0.08160996, 0.07753281, 0.07456368, 0.07238582])

Several important quantities that were setup when the model was defined by the configuration file are located in the model section of the simulation. For example, the inner and outer velocity boundaries of the zones in the model is given by simulation.simulation_state.v_inner.cgs and simulation.simulation_state.v_outer.cgs respectively. These exist as Astropy Quantities.

[5]:
simulation.simulation_state.v_inner.cgs
[5]:
$[1.1 \times 10^{9},~1.145 \times 10^{9},~1.19 \times 10^{9},~1.235 \times 10^{9},~1.28 \times 10^{9},~1.325 \times 10^{9},~1.37 \times 10^{9},~1.415 \times 10^{9},~1.46 \times 10^{9},~1.505 \times 10^{9},~1.55 \times 10^{9},~1.595 \times 10^{9},~1.64 \times 10^{9},~1.685 \times 10^{9},~1.73 \times 10^{9},~1.775 \times 10^{9},~1.82 \times 10^{9},~1.865 \times 10^{9},~1.91 \times 10^{9},~1.955 \times 10^{9}] \; \mathrm{\frac{cm}{s}}$
[6]:
simulation.simulation_state.v_outer.cgs
[6]:
$[1.145 \times 10^{9},~1.19 \times 10^{9},~1.235 \times 10^{9},~1.28 \times 10^{9},~1.325 \times 10^{9},~1.37 \times 10^{9},~1.415 \times 10^{9},~1.46 \times 10^{9},~1.505 \times 10^{9},~1.55 \times 10^{9},~1.595 \times 10^{9},~1.64 \times 10^{9},~1.685 \times 10^{9},~1.73 \times 10^{9},~1.775 \times 10^{9},~1.82 \times 10^{9},~1.865 \times 10^{9},~1.91 \times 10^{9},~1.955 \times 10^{9},~2 \times 10^{9}] \; \mathrm{\frac{cm}{s}}$

The average density in the zones is given by simulation.simulation_state.density.cgs. These also exist as Astropy Quantities.

[7]:
simulation.simulation_state.density.cgs
[7]:
$[7.5428036 \times 10^{-14},~5.728475 \times 10^{-14},~4.3960742 \times 10^{-14},~3.4062874 \times 10^{-14},~2.6631346 \times 10^{-14},~2.0995965 \times 10^{-14},~1.6682872 \times 10^{-14},~1.3353105 \times 10^{-14},~1.0761538 \times 10^{-14},~8.7290848 \times 10^{-15},~7.1236516 \times 10^{-15},~5.8469209 \times 10^{-15},~4.8250928 \times 10^{-15},~4.0023242 \times 10^{-15},~3.3360386 \times 10^{-15},~2.7935404 \times 10^{-15},~2.3495504 \times 10^{-15},~1.9843968 \times 10^{-15},~1.6826769 \times 10^{-15},~1.4322598 \times 10^{-15}] \; \mathrm{\frac{g}{cm^{3}}}$

Many other interesting quantities are stored in the plasma. For example the calculated ion populations and level populations is given by simulation.plasma.ion_number_density and simulation.plasma.level_number_density respectively.

[8]:
simulation.plasma.ion_number_density
[8]:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
atomic_number ion_number
8 0 9.627467e+02 4.900672e+02 2.473974e+02 1.274211e+02 8.535302e+01 4.655405e+01 3.264196e+01 2.224713e+01 1.473045e+01 1.137620e+01 8.094312e+00 6.093331e+00 4.742241e+00 3.567553e+00 2.913938e+00 2.360576e+00 2.001795e+00 1.502125e+00 1.224113e+00 1.053713e+00
1 5.391938e+08 4.093591e+08 3.139299e+08 2.429415e+08 1.899244e+08 1.494287e+08 1.187441e+08 9.500885e+07 7.649737e+07 6.210986e+07 5.067495e+07 4.160745e+07 3.435649e+07 2.850144e+07 2.377555e+07 1.991999e+07 1.676535e+07 1.415826e+07 1.200916e+07 1.022667e+07
2 2.334049e+05 3.158333e+05 4.577747e+05 6.610742e+05 5.311638e+05 7.251692e+05 5.644436e+05 4.866706e+05 4.644070e+05 3.167149e+05 2.702699e+05 2.071594e+05 1.504464e+05 1.214237e+05 8.233398e+04 5.818571e+04 3.759760e+04 3.327662e+04 2.460230e+04 1.622335e+04
3 2.983489e-08 8.500618e-08 2.857211e-07 9.433110e-07 6.915038e-07 1.947953e-06 1.295304e-06 1.110710e-06 1.226286e-06 5.693060e-07 4.662116e-07 2.884118e-07 1.545870e-07 1.079759e-07 4.808868e-08 2.369971e-08 9.254300e-09 8.033072e-09 4.388033e-09 1.783771e-09
4 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
20 16 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
17 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
18 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
19 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
20 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00

94 rows × 20 columns

[9]:
simulation.plasma.level_number_density
[9]:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
atomic_number ion_number level_number
8 0 0 503.454311 255.953833 129.010195 66.341424 44.480144 24.227915 17.005934 11.597611 7.680532 5.941131 4.229929 3.187705 2.484077 1.870334 1.529986 1.241086 1.054180 0.791399 0.645640 0.556596
1 295.929658 150.474039 75.859803 39.017510 26.157116 14.249971 10.000916 6.819828 4.516332 3.492798 2.486569 1.873627 1.459805 1.099003 0.898826 0.728968 0.619040 0.464698 0.379048 0.326698
2 97.767233 49.716146 25.066037 12.893515 8.643297 4.709077 3.304731 2.253486 1.492323 1.154015 0.821528 0.618982 0.482233 0.363027 0.296877 0.240754 0.204427 0.153454 0.125162 0.107865
3 64.172047 33.167856 17.059910 8.950937 5.930996 3.286427 2.275772 1.539737 1.017265 0.770679 0.544045 0.404128 0.309500 0.230345 0.184490 0.146859 0.121817 0.090851 0.072914 0.061452
4 1.252559 0.659582 0.347109 0.186303 0.121813 0.068818 0.046931 0.031469 0.020735 0.015344 0.010728 0.007840 0.005888 0.004325 0.003382 0.002636 0.002128 0.001576 0.001241 0.001020
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
20 16 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
17 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
18 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
19 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
20 0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

4435 rows × 20 columns

These are stored as Pandas DataFrames. An index can be supplied to obtain the population in a particular zone. E.g., for the ion populations of the innermost zone (index = 0), we will use simulation.plasma.ion_number_density[0]

[10]:
simulation.plasma.ion_number_density[0]
[10]:
atomic_number  ion_number
8              0             9.627467e+02
               1             5.391938e+08
               2             2.334049e+05
               3             2.983489e-08
               4             0.000000e+00
                                 ...
20             16            0.000000e+00
               17            0.000000e+00
               18            0.000000e+00
               19            0.000000e+00
               20            0.000000e+00
Name: 0, Length: 94, dtype: float64

Ion populations for a particular ionization stage of a particular element can be accessed by specifying an appropriate tuple (𝑍,𝐶), which identifies the element (via atomic number 𝑍 ) and the charge (via the ion charge 𝐶 ). Thus, simulation.plasma.ion_number_density.loc[14,1] will identify the ion popuations for Si II (𝑍=14,𝐶=1) in all the zones.

[11]:
simulation.plasma.ion_number_density.loc[14,1]
[11]:
0     69222.990490
1     34434.155139
2     16882.071743
3      8428.517781
4      5731.277465
5      3033.145732
6      2165.030122
7      1488.652827
8       985.070930
9       784.464062
10      563.818866
11      433.057758
12      345.578679
13      264.062340
14      222.468476
15      185.167056
16      162.494316
17      122.936059
18      102.515802
19       91.124039
Name: (14, 1), dtype: float64

The above examples can be combined to obtain e.g. the Si II population in the innermost zone can be obtained by simulation.plasma.ion_number_density[0].loc[14,1]

[12]:
simulation.plasma.ion_number_density[0].loc[14,1]
[12]:
np.float64(69222.99049002765)

The level populations are stored (and can be accessed) in a similar way - a third label can be used to pick out a particular atomic level. E.g., to pull out the population of the ground state (index 0) of Si II we can use simulation.plasma.level_number_density.loc[14,1,0]

[13]:
simulation.plasma.level_number_density.loc[14,1,0]
[13]:
0     23433.262398
1     11649.070689
2      5706.503262
3      2846.592693
4      1936.621087
5      1024.156087
6       731.460253
7       503.113358
8       332.953160
9       265.373180
10      190.796307
11      146.628353
12      117.085000
13       89.504283
14       75.462078
15       62.849442
16       55.196488
17       41.767939
18       34.847798
19       30.996439
Name: (14, 1, 0), dtype: float64

Notes

  • If you prefer to work in SI units, all the Astropy Quantities may instead by accessed with “xxx.si”.

  • Information that is not stored as Astropy Quantities (e.g. the ion and level populations used in the example above) are usually stored in cgs units (i.e. cm−3 for the populations).